home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / Source / Chapter 13 / Game / Weapon.h < prev   
Encoding:
C/C++ Source or Header  |  2004-10-01  |  2.3 KB  |  58 lines

  1. //-----------------------------------------------------------------------------
  2. // Provides the functionality for a weapon that can be used by a player object.
  3. //
  4. // Programming a Multiplayer First Person Shooter in DirectX
  5. // Copyright (c) 2004 Vaughan Young
  6. //-----------------------------------------------------------------------------
  7. #ifndef WEAPON_H
  8. #define WEAPON_H
  9.  
  10. //-----------------------------------------------------------------------------
  11. // Weapon Class
  12. //-----------------------------------------------------------------------------
  13. class Weapon
  14. {
  15. public:
  16.     Weapon( Script *script, D3DXVECTOR3 viewWeaponOffset );
  17.     virtual ~Weapon();
  18.  
  19.     void Update( float elapsed, bool fire, SceneObject *parent, float viewPointY );
  20.     void Render( SceneObject *parent );
  21.  
  22.     void RaiseLowerWeapon( float elapsed, SceneObject *parent, float move );
  23.  
  24.     void UseViewWeapon( bool use );
  25.  
  26.     char *GetName();
  27.  
  28.     void SetValid( bool valid );
  29.     bool GetValid();
  30.  
  31. private:
  32.     char *m_name; // Name of the weapon.
  33.     bool m_valid; // Indicates if the weapon is valid.
  34.     D3DXVECTOR3 m_viewWeaponOffset; // Offset to display the weapon at in the 1st person view.
  35.  
  36.     float m_lastViewPointY; // Stores the latest view point y value passed to the Update() function.
  37.     float m_offsetViewPointY; // Maintains the offset for smoothing out 1st person weapon movement during animation.
  38.  
  39.     float m_rof; // Weapon's rate of fire.
  40.     float m_velocity; // Velcotiy that the weapon fires its bullets at.
  41.     float m_damage; // Damage caused by this weapon's bullets.
  42.     float m_range; // Range the weapon can fire a bullet.
  43.  
  44.     float m_fireTimer; // Timer used for firing the weapon.
  45.     D3DXVECTOR3 m_muzzelPoint; // Point at the end of the weapon's barrel in world space.
  46.  
  47.     bool m_useViewWeapon; // Indicates if the weapon should use the 1st person view mesh.
  48.     SceneObject *m_bodyWeapon; // Object representing the 3rd person weapon.
  49.     SceneObject *m_viewWeapon; // Object representing the 1st person weapon.
  50.  
  51.     bool m_displayFlash; // Indicates if a flash sould be displayed in the current frame.
  52.     LinkedList< Material > *m_flashes; // Linked list of flashes used by this weapon.
  53.  
  54.     Sound *m_shotSound; // Shot sound made by this weapon.
  55.     AudioPath3D *m_shotAudioPath; // Audio path used for playing the shot sound.
  56. };
  57.  
  58. #endif